package com.qf.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.event.util.EventUtil;
import com.qf.dao.RoomPriceDao;
import com.qf.entity.PricesParams;
import com.qf.entity.RoomPrice;
import com.qf.service.RoomPriceService;
import com.qf.service.RoomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * (RoomPrice)表服务实现类
 *
 * @author makejava
 * @since 2020-09-15 15:56:14
 */
@Service("roomPriceService")
public class RoomPriceServiceImpl extends ServiceImpl<RoomPriceDao, RoomPrice> implements RoomPriceService {

    @Autowired
    private RoomService roomService;

    @Autowired
    private EventUtil eventUtil;

//    @Autowired
//    private SearchFeign searchFeign;

    @Autowired
    private RoomPriceDao roomPriceDao;

    @Override
    public boolean updateById(RoomPrice entity) {
        boolean flag = super.updateById(entity);

//        Room room = roomService.getById(entity.getRid());
        //修改的酒店客房价格同步到ES中
//        searchFeign.updateHotalRoomPrice(room.getHid(), entity);
        eventUtil.publishEvent("price_update", entity);

        return flag;
    }

    /**
     * 修改指定房间 在指定的时间范围内预订的房间数量
     * @param pricesParams
     * @return
     */
    @Override
    public int updateRoomNumber(PricesParams pricesParams) {
        return roomPriceDao.updateRoomNumber(pricesParams);
    }
}